class Solution:
    def computeArea(self, A: int, B: int, C: int, D: int, E: int, F: int, G: int, H: int) -> int:
        a1 = None
        b1 = None
        c1 = None
        d1 = None
        coincidence = None
        if A <= E <= C:
            a1 = E
            c1 = min(C, G)
        elif E <= A <= G:
            a1 = A
            c1 = min(C, G)
        else:
            coincidence = 0

        if coincidence is None:
            if B <= F <= D:
                b1 = F
                d1 = min(D, H)
            elif F <= B <= H:
                b1 = B
                d1 = min(D, H)
            else:
                coincidence = 0
        if coincidence is None:
            coincidence = (c1 - a1) * (d1 - b1)
        return (C - A) * (D - B) + (G - E) * (H - F) - coincidence


if __name__ == '__main__':
    so = Solution()
    r = so.computeArea(-3, 0, 3, 4, 0, -1, 9, 2)
    print(r)
